package cc.htdf.gwc.observation.service;

import cc.htdf.gwc.observation.repository.ObserveDataRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

/**
 * Created by JT on 2017/10/11.
 */
@Service
public class ObserveDataServiceImpl implements ObserveDataService {

    @Autowired
    private ObserveDataRepository observeDataRepository;


    /**
     * 根据站号、观测时间、要素查询观测数据
     *
     * @param stations ：站号
     * @param date     ：时间
     * @param elements ：要素
     * @return
     */
    @Override
    public List<Map<String, Object>> fetchObserveDateByStationsAndDate(String stations, String date, String elements) {
        List<String> stationList = Arrays.asList(stations.split(","));
        return observeDataRepository.fetchObserveDataByStationsAndDate(stationList, date, elements);
    }

    /**
     * 根据站号、观测时间、要素查询观测数据
     *
     * @param stations ：站号
     * @param startDate     ：时间
     * @param endDate     ：时间
     * @param elements ：要素
     * @return
     */
    @Override
    public List<Map<String, Object>> observeDate(String stations, String startDate, String endDate, String elements) {
        List<String> stationList = Arrays.asList(stations.split(","));
        return observeDataRepository.observeData(stationList, startDate,endDate, elements);
    }

    /**
     * 根据站号获取观测数据
     *
     * @param station
     * @return
     */
    @Override
    public List<Map<String, Object>> fetchChengDuObserveDataByStationId(String station, String elements) {
        return observeDataRepository.fetchChengDuObserveDataByStationId(station, elements);
    }


}
